home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs58.d81 / filedial.seq (.txt) < prev    next >
GEOS ConVerT  |  2009-10-10  |  24KB  |  877 lines

  1. Stage
  2. PRG formatted GEOS file V1.0
  3. LA-50
  4. 4!STAGE
  5. BLASTER'S CONVERTER V2.5
  6. ,'RunDA
  7. 4$DL.lnk
  8. Write Image V2.1
  9. geoWrite    V2.0
  10. 0  This module contains the source code for an advanced Geos 64 Listbox.
  11.     This source file was written by
  12. Joseph Buckley.
  13.     Major portions of this file were
  14. written by William Coleman and available
  15. from him directly.
  16.     You are free to use this code in
  17. your own programs and to modify it to suit your
  18. programming needs but please make notes where
  19. any modifications are made.
  20.     For more information contact:
  21.     Joseph Buckley
  22.     464 Beale St.
  23.     W. Quincy, MA 02169-1307
  24.     Red Storm via Quantum Link
  25.     71570,2600 via CompuServe
  26.     (GEOS Section Leader, CBMPRG forum)
  27.     There are two custom assembly
  28. macros used in this file:
  29. .macro    ClrB    dest
  30.     lda    #$00
  31.     sta    dest
  32. .endm
  33. .macro    ClrW    dest
  34.     lda    #$00
  35.     sta    dest
  36.     sta    dest+1
  37. .endm
  38.     The two routines 'WhichMode' and
  39. 'GeneralError' may
  40.     There are two custom assembly
  41. macros used in this file:
  42. .macro    ClrB    dest
  43.     lda    #$00
  44.     sta    dest
  45. .endm
  46. .macro    ClrW    dest
  47.     lda    #$00
  48.     sta    dest
  49.     sta    dest+1
  50. .endm
  51.     The two routines 'WhichMode' and
  52. 'GeneralError' may be found in the companion
  53. file 'RunDA'.
  54. .if    Pass1
  55. .noeqin
  56. .noglbl
  57. .include    geosSym
  58. .include    geosMac
  59. .eqin
  60. .glbl
  61. .endif
  62. BOXWITH        = 124    ;Width of filebox
  63. NAMEHITE        = 10    ;Height of name region
  64. MAX_IN_VIEW        = 7    ;Number of files sho
  65. .if    Pass1
  66. .noeqin
  67. .noglbl
  68. .include    geosSym
  69. .include    geosMac
  70. .eqin
  71. .glbl
  72. .endif
  73. BOXWITH        = 124    ;Width of filebox
  74. NAMEHITE        = 10    ;Height of name region
  75. MAX_IN_VIEW        = 7    ;Number of files shown in box
  76. BOXHITE        = NAMEHITE*MAX_IN_VIEW+1
  77. BOXTOP        = DEF_DB_TOP+4
  78. BOXBOTTOM        = BOXTOP+BOXHITE
  79. BOXLEFT        = DEF_DB_LEFT+3
  80. BOXRIGHT        = BOXLEFT+BOXWITH
  81. Files_To_Get    = 160    ; number of files to search for
  82. Stage:
  83. ;   Preparation for this subroutine call is
  84. Stage:
  85. ;   Preparation for this subroutine call is
  86. ; minor:
  87. ;   Load the variable DATA_TYPE with the GEOS
  88. ; constant for the file type that you wish to
  89. ; search for (eg. NOT_GEOS, APPL_DATA, etc.).
  90. ;   If you wish to filter the GEOS files
  91. ; according to the 'Permanent Name String',
  92. ; you must change the contents of 'ClassString'
  93. ; to conform to the files you need.
  94. ;   You program's initialization routine must
  95. ; contain a call to 'InitDrives' and you must
  96. ; call 'ResetDrives' before calling
  97. ; 'EnterDeskTop'.
  98. ;   You program's initialization routine must
  99. ; also set the values of the two variables
  100. ; 'SourceDrive' and 'TargetDrive' to the value
  101. ; of 'curDrive'.
  102.     LoadB    selected,$01    ; select first file
  103.     jsr    i_FillRam    ; zero file name buffer
  104. .word    Files_To_Get*17
  105. .word    FNameBuffer
  106. .byte    0
  107.     jsr    OpenDisk    ; log current disk
  108.     jsr    DiskNames    ; get disk names
  109.     lda    curDrive    ; use curDrive as an index
  110.     sub    #$08    ; for current disk name
  111.     ldx    NamesLow,y    ; get proper name buffer
  112.     lda    NamesHigh,y
  113.     stx    r8L    ; use r8 for DB access
  114.     sta    r8H    
  115.     LoadW    r6,FNameBuffer    ; pointer to name buffer
  116.     ClrW    r10    ; default to no 'Class' string
  117.     LoadB    r7H,Files_To_Get    ; # of file names to seek
  118.     MoveB    DATA_TYPE,r7L    ; type of files to seek
  119.     beq    1$
  120.     LoadW    r10,ClassString    ; if a GEOS file, filter type
  121. ;   The 'ClassString' text is used to further
  122. ; filter the file types according to a string
  123. ; in the file header.
  124. ;   If you do not wish to use this feature,
  125. ; leave r10 at $0000.
  126. 1$    jsr    FindFTypes    ; get file names
  127.     lda    #Files_To_Get    ; max # sought
  128.     sub    r7H    ; minus # left to find
  129.     sta    FileTemp    ; store # found
  130.     LoadW    r0,DrivesDB
  131.     ClrW    Drive    ; default to one drive
  132.     lda    numDrives    ; do we have two?
  133.     cmp    #$01
  134.     beq    2$    ; no, then skip
  135.     LoadW    Drive,DriveIcon    ; yes, then use two drive dialog box
  136. 2$    ClrW    OldName    ; zero file name buffer
  137.     LoadW    r5,OldName    ; buffer for file name
  138.     jsr    DoDlgBox
  139.     lda    sysDBData    ; what DB choice was made?
  140.     cmp    #CANCEL    ; did we CANCEL?
  141.     bne    3$
  142. ;   Sinc
  143. 2$    ClrW    OldName    ; zero file name buffer
  144.     LoadW    r5,OldName    ; buffer for file name
  145.     jsr    DoDlgBox
  146.     lda    sysDBData    ; what DB choice was made?
  147.     cmp    #CANCEL    ; did we CANCEL?
  148.     bne    3$
  149. ;   Since this subroutine is designed to run
  150. ; from the main level of the application code,
  151. ; or actually the level called by a menu
  152. ; selection, we can quickly return to the menu
  153. ; handler by pulling one return address.  The
  154. ; next return address on the stack will bring
  155. ; us directly to the menu handler for a new
  156. ; selection.
  157.     pla        ; yes, CANCEL
  158. 3$    cmp    #DISK    ; change disks?
  159.     bne    4$
  160.     LoadW
  161. r0,DiskChange    ; yes, put up change DB
  162.     jsr    DoDlgBox
  163.     jmp    Stage    ; loop back to start
  164. 4$    cmp    #DBUSRICON    ; change drives?
  165.     bne    5$
  166.     jmp    Stage    ; yes, service routine does this
  167. 5$    MoveB    selected,r0    ; OPEN must have been selected
  168.     dec    r0    ; file name position in list
  169.     LoadB    r1,$11    ; 17 chars per name
  170.     ldx    #r0
  171.     ldy    #r1
  172.     jsr    BBMult    ; calc byte position in list
  173.     AddVW    FNameBuffer,r0    ; calc poisition in RAM
  174.     LoadW    r1,OldName
  175.     ldy    #r1
  176.     jsr    CopyString    ; copy to generic buffer
  177.     lda    OldName    ; is there a file name?
  178.     bne    DoNewName
  179.     LoadW    r0,NoFileDB    ; no, put up error DB
  180.     jsr    DoDlgBox
  181.     jmp    Stage
  182. DoNewName:
  183. ;   This rou
  184. DoNewName:
  185. ;   This routine may be removed for any
  186. ; application which does not require the
  187. ; generation of a new file name.
  188. ;   The new name defaults to the old name with
  189. ; the addition of the '+' character at the end.
  190. ; if the old name contained 16 characters, then
  191. ; the last character will be replaced by the
  192. ; '+'.
  193.     LoadW    r0,OldName
  194.     LoadW    r1,NewName
  195.     ldx    #r0
  196.     ldy    #r1
  197.     jsr    CopyString    ; copy to new name buffer
  198.     ldy    #$00
  199. 1$    lda    NewName,y    ; search for terminator
  200.     beq    2$
  201.     cpy    #$10
  202.     bne    1$
  203. 2$    lda    #$2b
  204.     sta    NewName,y    ; add '+'
  205.     lda    #$00
  206.     sta    NewName,y
  207.     ; add terminator
  208.     sty    NewLength
  209. DriveDecision:
  210.     ClrW    Drive    ; set for one drive
  211. DriveDecision:
  212.     ClrW    Drive    ; set for one drive
  213.     lda    numDrives    ; test for more
  214.     cmp    #$01
  215.     beq    1$
  216.     LoadW    Drive,DriveIcon    ; set for two or more drives
  217. 1$    MoveB    curDrive,SourceDrive
  218. ;              flag drive which has original
  219. ;              file on it
  220.     jsr    GetNewName    ; test for valid default file name
  221. 2$    LoadW    r5,NewName    ; file name text for DB
  222.     LoadW    r0,TargetDisk    ; manual file name generator
  223.     jsr    DoDlgBox
  224.     lda    sysDBData
  225.     cmp    #CANCEL    ; did we CANCEL?
  226.     bne    3$
  227.     pla        ; yes, pull return address
  228.     pla        ; for same reason as earlier
  229. 3$    cmp    #DBUSRICON    ; did we change drives?
  230.     beq    2$    ; if so, run options again
  231.     LoadW    r6,NewName    ; search for this new name
  232.     jsr    FindFile    ; do it
  233.     cpx    #$05    ; 'File Not Found'?
  234.     beq    5$    ; if not found, valid name, continue
  235.     bne    4$    ; if other error, flag it
  236.     LoadW    r0,FileExists    ; only if not found
  237.     jsr    DoDlgBox    ; call this DB
  238.     bra    2$
  239. 4$    jsr    GeneralError    ; otherwise, generate generic error DB
  240.     bra    2$    ; try for new name option
  241. 5$    MoveB    curDrive,TargetDrive
  242. ;              curDrive is where Target file should go
  243.     rts        ; finished
  244. GetNewName:
  245. ;   This routine will search the TargetDrive
  246. ; for the NewName.  If it is found, then a new
  247. ; file name is generated by incrementing the
  248. GetNewName:
  249. ;   This routine will search the TargetDrive
  250. ; for the NewName.  If it is found, then a new
  251. ; file name is generated by incrementing the
  252. ; value of the character preceding the '+' by
  253. ; one.
  254.     jsr    GotoTarget
  255.     LoadW    r6,NewName
  256.     jsr    FindFile    ; search for file
  257.     cpx    #$00    ; no error?
  258.     bne    2$    ; if error, assume 'Not Found'
  259.     dec    NewLength    ; create pointer to char
  260.     dec    NewLength    ; before '+'/NULL pair
  261.     lda    #'/'    ; default to '/' [ASCII(0)-1]
  262.     ldx    NewLength    ; new index
  263.     sta    NewName,x    ; change char
  264. 1$    ldx    NewLength    ; new index
  265.     inc    NewName,x    ; increment char from '0' onward
  266.     LoadW    r6,NewName
  267.     jsr    FindFile    ; search for file
  268.     cpx    #$00    ; no error?
  269.     beq    1$    ; if none, it was found and
  270. ;              must continue generating
  271. ;              new names
  272. ;              if error, assume 'Not Found'
  273. 2$    rts        ; exit
  274. FileExists:
  275. .byte    DEF_DB_POS | $01
  276. .byte    DB_USR_ROUT
  277. .word    SetWindow
  278. .byte    DBTXTSTR,$01,$01
  279. .word    ExistsText
  280. .byte    OK,$11,$40,$00
  281. ExistsText:
  282. .byte    CR,CR,BOLDON,"  This file already exists.",0
  283. DiskChange:
  284. .byte    DEF_DB_POS | $01
  285. .byte    DBTXTSTR,$08,$1e
  286. .word    InsrtNDsk
  287. .byte    OK,$11,$41,0
  288. InsrtNDsk:
  289. .byte    BOLDON,"Please insert new disk.",0
  290. NoFileDB:
  291. .byte    DEF_DB_POS | $01
  292. .byte    DBTXTSTR,$08,$1e
  293. .word    FilNotFnd
  294. .byte    OK,$11,$41,0
  295. FilNotFnd:
  296. .byte    BOLDON,"File not found.",0
  297. TargetDisk:
  298. .byte    DEF_DB_POS | $01
  299. .byte    DB_USR_ROUT
  300. .word    SetWindow
  301. .byte    DBTXTSTR,$01,$01
  302. .word    TargetText
  303. .byte    DB_USR_ROUT
  304. .word    PrintDrive
  305. .byte    DBGETSTRING,$18,$28,r5,$10
  306. .byte    DBUSRICON,$0a,$40
  307. .word    Drive
  308. .byte    CANCEL,$11,$40,0
  309. TargetText:
  310. .byte    CR,CR,BOLDON,"Please enter filename on",CR,"Drive ",0
  311. PrintDrive:
  312.     lda    curDrive
  313.     adc    #56
  314.     jsr    PutChar
  315.     lda    #':'
  316.     jsr    PutChar
  317.     lda    #PLAINTEXT
  318.     jmp    PutChar
  319. NamesLow:
  320. .byte    <DriveAName,<DriveBName,<DriveCName
  321. NamesHigh:
  322. .byte    >DriveAName,>DriveBName,>DriveCName
  323. DiskNames:        ; save disk names to text buffers for target drive DB
  324.     LoadW    r0,DrACurDkNm
  325.     LoadW    r1,DriveAName
  326.     jsr    CopyNames
  327.     LoadW    r0,DrBCurDkNm
  328. DiskNames:        ; save disk names to text buffers for target drive DB
  329.     LoadW    r0,DrACurDkNm
  330.     LoadW    r1,DriveAName
  331.     jsr    CopyNames
  332.     LoadW    r0,DrBCurDkNm
  333.     LoadW    r1,DriveBName
  334.     jsr    CopyNames
  335.     LoadW    r0,DrCCurDkNm
  336.     LoadW    r1,DriveCName
  337. CopyNames:
  338.     ldy    #$00
  339. 1$    MoveB    "(r0),y","(r1),y"
  340.     bmi    2$
  341.     cpy     #$10
  342.     bne    1$
  343. 2$    ClrB    
  344. "(r1),y"
  345. ClassString:
  346. .byte    "Paint Image",0
  347. DrivesDB:
  348. .byte    DEF_DB_POS | $01
  349. .byte    DB_
  350. DrivesDB:
  351. .byte    DEF_DB_POS | $01
  352. .byte    DB_USR_ROUT
  353. .word    DecrRMargin
  354. .byte    DBTXTSTR,$83,$09
  355. .word    OnDisk
  356. .byte    DBVARSTR,$83,$11,r8
  357. .byte    OPEN,$11,$17
  358. .byte    DISK,$11,$29
  359. .byte    DBUSRICON,$11,$3b
  360. .word    Drive
  361. .byte    CANCEL,$11,$4d
  362. .byte    DB_USR_ROUT
  363. .word    InitFBox
  364. .byte    0
  365. DecrRMargin:
  366.     dec    rightMargin
  367. OnDisk:
  368. .byte    BOLDON,"On disk:",PLAINTEXT,0
  369. DriveIcon:
  370. Drive:
  371. .word    DriveIcon,0
  372. .byte    6,16
  373. .word    ScrollDrive
  374. ScrollDrive:
  375.     jsr    SwapDrive
  376.     LoadB    
  377. sysDBData,
  378. DBUSRICON
  379.     jmp    RstrFrmDialog
  380. GotoSource:
  381.     lda    SourceDrive
  382.     bra    GotoDrive
  383. GotoTarget:
  384.     lda    TargetDrive
  385. GotoDrive:
  386. ;   Pass drive number in A
  387.     cmp    curDrive
  388.     beq    1$
  389.     sta    WorkDrive
  390.     jsr    SetDevice
  391.     jsr    OpenDisk
  392. 1$    rts
  393. InitDrives:
  394. ;   Initialize drive access for up to three
  395. ; drives on an REU equipped system.
  396.     jsr    WhichMode    ; test graphic mode
  397.     bpl    1$
  398.     LoadB    Drive+$04,$86    ; set doubling bit 
  399. InitDrives:
  400. ;   Initialize drive access for up to three
  401. ; drives on an REU equipped system.
  402.     jsr    WhichMode    ; test graphic mode
  403.     bpl    1$
  404.     LoadB    Drive+$04,$86    ; set doubling bit for GEOS 128
  405. 1$    MoveB    curDrive,BootDrive    ; mark boot disk for exit
  406.     sta    WorkDrive    ; flag as current drive
  407.     MoveB    numDrives,TotalDrives
  408. ;              store entry value of numDrives
  409. ;              for recovery on exit
  410.     cmp    #$01
  411.     beq    3$    ; if 1, then don't bother with
  412. ;              third drive testing
  413. ;              if 2, check to see if third
  414. ;              drive possible
  415.     lda    version    ; must be V2.0 for third drive
  416.     cmp    #$20
  417.     bcc    3$    ; if not, then exit
  418.     lda    driveType+2    ; is there a third drive?
  419.     beq    3$    ; if not, then exit
  420.     and    #$0f    ; strip RAM flags
  421.     sta    maxDrives    ; store it
  422.     lda    driveType    ; test with drive A
  423.     and    #$0f    ; strip RAM flags
  424.     cmp    maxDrives    ; test it
  425.     beq    2$    ; if same, no need for REU
  426.     lda    sysRAMFlg    ; check for REU device
  427.     and    #%01000000    ; driver storage
  428.     beq    3$    ; if none, then exit
  429. 2$    inc    numDrives    ; add one to numDrives
  430. 3$    jmp    NewDisk    ; exit/log active disk
  431. SwapDrive:
  432.     ldx    numDrives    ; check for only one drive
  433.     bne    1$
  434.     rts        ; don't bother if only one
  435. 1$    jsr    NextDrive    ; get next drive number
  436.     sta    WorkDrive    ; flag new drive as curre
  437. SwapDrive:
  438.     ldx    numDrives    ; check for only one drive
  439.     bne    1$
  440.     rts        ; don't bother if only one
  441. 1$    jsr    NextDrive    ; get next drive number
  442.     sta    WorkDrive    ; flag new drive as current
  443.     jmp    SetDevice    ; log new device
  444. NextDrive:
  445.     lda    numDrives    ; check for one drive
  446.     cmp    #$01
  447.     beq    3$
  448.     add    #$08    ; add offset for device #s
  449.     sta    maxDrives    ; highest highest device #
  450.     ldy    WorkDrive    ; get current device #
  451. 1$    iny        ; generate next device #
  452.     cpy    maxDrives    ; have we passed max value?
  453.     bcc    2$
  454.     ldy    #$08    ; too high, start at 8 again
  455. 2$    lda    driveType-8,y    ; get device type
  456.     beq    1$    ; is there an actual device?
  457.     tya        ; yes, return in A
  458. 3$    lda    WorkDrive    ; no, return old value in A
  459. ResetDrives:
  460.     lda    BootDrive    ; get file's boot drive
  461.     jsr    GotoDrive    ; activate it
  462.     MoveB    TotalDrives,numDrives
  463. ;              restore numDrives to value
  464. ;              saved on execution
  465.     lda    sysDBData
  466.     cmp    #CANCEL    ; did we CANCEL?
  467.     bne    3$
  468.     pla        ; yes, pull return 
  469. InitFBox:
  470. ;    pass:    A - # of entries (zero if no files)
  471. ;        Y - width of each entry
  472. ;        r15 - buffer of names
  473.     LoadW    keyVector,DBKeyHandle    ; my modification for cursor keys
  474.     LoadW    r15,FNameBuffer
  475.     lda    FileTemp
  476.     ldy    #$11
  477.     sty    nameWidth
  478.     sta    highest
  479.     lda    #15
  480.     jsr    SetPattern
  481.     MoveW    r15,list
  482.     jsr    FBoxPtrs    ;Set pointers to FileBox
  483.     LoadB    r2L,BOXBOTTOM+1
  484.     LoadB    r2H,BOXBOTTOM+16
  485.     jsr    Rectangle
  486.     LoadB    r2L,BOXTOP
  487.     lda    #$ff
  488.     jsr    FrameRectangle    ;Outline box
  489.     lda    highest
  490.     cmp    #MAX_IN_VIEW+1
  491.     bcc    2$
  492.     jsr    WhichMode
  493.     bpl    1$
  494.     LoadB    *+$0d,$80+BOXLEFT/8+4
  495.     LoadB    *+$0a,$80+12
  496. 1$    jsr    i_BitmapUp
  497. .word    fBoxIcons
  498. .byte    BOXLEFT/8+4,BOXBOTTOM+1,12,16
  499. 2$    LoadW    otherPressVec,DoButton
  500.     LoadB    ontop,$01
  501.     CmpBI    highest,#$08
  502.     bcc    4$
  503.     lda    selected
  504.     sub    #$04
  505.     bcs    3$
  506.     ldx    #$00
  507. 3$    inx
  508.     stx    ontop
  509. 4$    jmp    FillBox
  510. FBoxPtrs:
  511. ;    sets up box pointers
  512.     LoadB    r2L,BOXTOP
  513.     LoadB    r2H,BOXBOTTOM
  514.     LoadW    r3,BOXLEFT
  515.     LoadW    r4,BOXRIGHT
  516.     jsr    WhichMode
  517.     bpl    1$
  518.     asl    r3
  519.     rol    r3
  520. FBoxPtrs:
  521. ;    sets up box pointers
  522.     LoadB    r2L,BOXTOP
  523.     LoadB    r2H,BOXBOTTOM
  524.     LoadW    r3,BOXLEFT
  525.     LoadW    r4,BOXRIGHT
  526.     jsr    WhichMode
  527.     bpl    1$
  528.     asl    r3
  529.     rol    r3H    ; r3=r3*2
  530.     asl    r4
  531.     rol    r4H    ; r4=r4*2
  532. 1$    rts
  533. NBoxPtrs:
  534. ;    Set pointers to a filename area in box
  535. ;    pass: A = box # (0 to max_in_view-1)
  536.     sta    r0L
  537.     LoadB    r1L,NAMEHITE
  538.     ldy    #r1
  539.     ldx    #r0
  540.     jsr    BBMult
  541.     jsr    FBoxPtrs
  542.     inc    r2L
  543.     lda    r0L
  544.     add    r2L
  545.     sta    r2L
  546.     adc    #NAMEHITE
  547.     sta    r2H
  548.     inc    r3L
  549.     bne    1$
  550.     inc    r3H
  551. 1$    ldx    #r4
  552.     jmp    Ddec
  553. FillBox:
  554. ;    Fills the current box with names.
  555.     lda    highest
  556.     beq    5$    ;Nothing to fill with - exit
  557.     PushW    rightMargin
  558.     jsr    FBoxPtrs
  559.     MoveW    r4,rightMargin    ;Don't let text print out of box
  560.     dec    rightMargin
  561.     LoadB    fbTemp,0
  562.     jsr    SetPattern
  563.     LoadB    boxStyle,BOLDON    ;BOLDON,PLAINTEXT,etc
  564.     jsr    PutChar
  565. 1$    lda    fbTemp    ;Counter will count from 0 to max_in_view-1
  566.     jsr    NBoxPtrs    ;Get pointers to name box
  567.     jsr    Rectangle    ;Clear area
  568.     MoveW    r3,r11    ;Set up Horiz. text
  569.     lda    r2L    ;Add pointsize to Vert text
  570.     add    #8
  571.     sta    r1H
  572.     lda    fbTemp
  573.     add    ontop    ;Top list entry
  574.     cmp    highest    ;Past last entry?
  575.     beq    2$    ;Nope, continue
  576.     bcs    4$    ;Yep, we're done!
  577. 2$    tay
  578.     dey        ;make relative to 0
  579.     sty    r15
  580.     MoveB    nameWidth,r0
  581.     ldx    #r0
  582.     ldy    #r15
  583.     jsr    BBMult    ;width * entry #
  584.     AddW    list,r0    ;add address of list
  585.     jsr    PutString    ;Print name
  586.     inc    fbTemp
  587.     lda    fbTemp
  588.     cmp    #MAX_IN_VIEW
  589.     bne    1$
  590. 4$    jsr    Invert    ;Invert selected name
  591.     PopW    rightMargin
  592. 5$    rts
  593. ScrollUp:
  594.     lda    highest
  595.     beq    ScrollEr
  596. ScrollUp:
  597.     lda    highest
  598.     beq    ScrollErr
  599.     ldx    ontop
  600.     cpx    selected
  601.     bcc    1$
  602.     beq    ScrollErr
  603.     jsr    Scroll_
  604.     dec    selected
  605.     jmp    DoAgain    ;redraw box & check button
  606. 1$    jsr    Invert
  607.     dec    selected
  608.     jmp    S_Up_Down
  609. ScrollDown:
  610.     lda    highest
  611.     beq    ScrollErr
  612.     cmp    selected
  613.     beq    ScrollErr
  614.     ldx    ontop
  615.     lda    selected
  616.     sub    ontop
  617.     cmp    #MAX_IN_VIEW-1
  618.     bcc    1$
  619.     jsr    Scroll_
  620.     inc    selected
  621.     jmp    DoAgain
  622. 1$    jsr    Invert
  623.     inc    selected
  624. S_Up_Down:
  625.     jsr    Invert
  626.     lda    mouseData    ;if mouse button is still
  627.     bmi    1$    ;press then recall CheckIcons
  628.     jmp    CheckIcons    ;to process command again
  629. 1$    rts
  630. Scroll_:
  631.     pha        ;Save new top-of-box
  632.     jsr    Invert    ;Clear selected name
  633.     sta    ontop
  634. ScrollErr:
  635.     jmp    HiBeep
  636. Invert:
  637. ;    inverts name box whos # in stored in selected
  638.     lda    selected    ;Get name box #
  639.     sub    ontop    ;Offset from top box #
  640.     jsr    NBoxPtrs    ;Set pointers
  641.     jmp    InvertRectangle
  642. ;    Far Scrolling - Scroll box to the very top or bottom or up or
  643. ;        down a page. These routines are called by CheckIcons
  644. BotScroll:
  645.     CmpB    highest,selected
  646.     bne    1$
  647.     jmp    ScrollErr
  648. 1$    MoveB    highest,selected
  649.     sub    #MAX_IN_VIEW-1
  650.     bcs    2$    ;ensure ontop > 0
  651.     bne    2$    ;ensure ontop not 0
  652.     lda    #1
  653. 2$    sta    ontop
  654.     jmp    FillBox
  655. TopScroll:
  656.     CmpBI    ontop,$01
  657.     bne    1$
  658.     jmp    ScrollErr
  659. 1$    LoadB    ontop,$01
  660.     sta    selected
  661.     jmp    FillBox
  662. PageUp:
  663.     lda    ontop
  664.     cmp    #1
  665.     beq    ScrollErr
  666.     cmp    #MAX_IN_VIEW
  667.     bcc    TopScroll
  668.     sub    #MAX_IN_VIEW-1
  669.     sta    ontop
  670.     sta    selected
  671.     jmp    DoAgain
  672. PageDown:
  673.     lda    highest
  674.     sub    #MAX_IN_VIEW
  675.     sta    fbTemp
  676.     cmp    ontop
  677.     bcc    ScrollErr
  678.     lda    ontop
  679.     add    #MAX_IN_VIEW-1
  680.     cmp    fbTemp
  681.     bcs    BotScroll
  682.     sta    ontop
  683.     sta    selected
  684. DoAgain:
  685.     jsr    FillBox    ;re-draw box
  686.     lda    mouseData    ;if mouse button is still
  687.     bmi    1$    ;press then recall CheckIcons
  688.     jmp    CheckIcons    ;to process command again
  689. 1$    rts
  690. DoButton:
  691. ;    Mouse button handler. Wedged into otherPressVector
  692.     lda    mouseData
  693.     bmi    4$    ;Ignore releases
  694.     lda    
  695. DoButton:
  696. ;    Mouse button handler. Wedged into otherPressVector
  697.     lda    mouseData
  698.     bmi    4$    ;Ignore releases
  699.     lda    highest
  700.     beq    4$    ;Box empty - exit
  701.     jsr    FBoxPtrs    ;check if mouse in filebox
  702.     LoadB    r2H,BOXBOTTOM-2
  703.     jsr    IsMseInRegion
  704.     cmp    #0
  705.     beq    CheckIcons    ;nope
  706.     jsr    Invert    ;Restore current selection
  707.     jsr    FBoxPtrs
  708.     lda    mouseYPos
  709.     sub    #BOXTOP
  710.     sta    r0L    ;Convert mouseY to 0 offset
  711.     ClrB    r0H
  712.     sta    r1H
  713.     LoadB    r1L,NAMEHITE
  714.     ldx    #r0
  715.     ldy    #r1
  716.     jsr    Ddiv    ;mouseY/nameHite = name #
  717.     lda    r0L
  718.     add    ontop    ;Result = selection #
  719.     cmp    highest
  720.     bcc    1$    ;Branch if not passed last name
  721.     lda    highest
  722.     ldx    dblClickCount
  723.     beq    2$
  724.     cmp    selected
  725.     bne    3$
  726.     jmp    DBDoCR
  727.     ldx    #$3f
  728.     stx    dblClickCount
  729. 3$    sta    selected
  730.     jsr    Invert
  731. 4$    rts
  732. CheckIcons:
  733.     lda    highest
  734.     cmp    #MAX_IN_VIEW+1
  735.     bcc    5$
  736.     LoadB    fbTemp,5
  737. 1$    LoadB    r2L,BOXBOTTOM+1
  738.     LoadB    r2H,BOXBOTTOM+16
  739.     ldy    fbTemp
  740.     lda    iconXLTab,y
  741.     sta    r4L
  742.     sub    #1
  743. CheckIcons:
  744.     lda    highest
  745.     cmp    #MAX_IN_VIEW+1
  746.     bcc    5$
  747.     LoadB    fbTemp,5
  748. 1$    LoadB    r2L,BOXBOTTOM+1
  749.     LoadB    r2H,BOXBOTTOM+16
  750.     ldy    fbTemp
  751.     lda    iconXLTab,y
  752.     sta    r4L
  753.     sub    #15
  754.     sta    r3L
  755.     ClrB    r3H
  756.     sta    r4H
  757.     jsr    WhichMode
  758.     bpl    2$
  759.     asl    r3L
  760.     rol    r3H
  761.     asl    r4L
  762.     rol    r4H
  763. 2$    jsr    IsMseInRegion    ;check if on icon
  764.     cmp    #0
  765.     beq    4$    ;nope - branch
  766.     jsr    InvertRectangle    ;flash icon
  767.     ldy    #40
  768.     ldx    #0    ;now waste some time
  769. 3$    inx
  770.     bne    3$
  771.     bne    3$
  772.     jsr    InvertRectangle    ;back to normal
  773.     lda    fbTemp    ;get execution address
  774.     asl    a        ;from table
  775.     lda    iconExecTab+1,y    ;push it on the stack
  776.     lda    iconExecTab,y
  777.     rts        ;and 'jump' to it
  778. 4$    dec    fbTemp
  779.     bpl    1$
  780. 5$    rts
  781. CANCEL    ; did we CANCEL?
  782.     bne    3$
  783.     pla        ; yes, pull return 
  784. ;  This is the main routine to generate the tone
  785. ;whose freq is passed in X.
  786. ;  The volume of the SID will be left turned up
  787. ; (the tone will continue for a bit after the routine
  788. ;returns)
  789. HiBeep:
  790.     ldx    #20
  791. Beep:
  792.     LoadB    CPU_DATA,IO_IN    ;take this out for Geos 128
  793.     stx    sidbase+1
  794.     ldy    #0
  795.     sty    sidbase+5    ;Y will be used in loop
  796.     LoadB    sidbase+6,%11111001
  797.     LoadB    sidbase+15,55
  798.     LoadB    sidbase+24,15
  799.     ldx    #%00010101
  800.     stx    sidbase+4        ;Gate sound on
  801. 1$    dey
  802.     bne    1$
  803.     bne    1$
  804.     LoadB    sidbase+4,%00010100  ;gate off
  805.     LoadB    CPU_DATA,RAM_64K
  806. DBKeyHandle:
  807.     lda    keyData
  808.     cmp    #CR
  809.     beq    DBDoCR
  810.     cmp    #KEY_UP
  811.     beq    DBDo_UP
  812.     cmp    #KEY_DOWN
  813.     beq    DBDo_DOWN
  814.     cmp    #KEY_LEFT
  815.     beq    DBDo_Paging
  816. DBKeyHandle:
  817.     lda    keyData
  818.     cmp    #CR
  819.     beq    DBDoCR
  820.     cmp    #KEY_UP
  821.     beq    DBDo_UP
  822.     cmp    #KEY_DOWN
  823.     beq    DBDo_DOWN
  824.     cmp    #KEY_LEFT
  825.     beq    DBDo_Paging
  826.     cmp    #KEY_RIGHT
  827.     beq    DBDo_Paging
  828. DBDoCR:
  829.     LoadB    sysDBData,OPEN
  830.     jmp    RstrFrmDialog
  831. DBDo_UP:
  832.     jmp    ScrollUp
  833. DBDo_DOWN:
  834.     jmp    ScrollDown
  835. DBDo_Paging:
  836.     ldx    highest
  837.     cpx    #MAX_IN_VIEW
  838.     bcs    1$
  839. 1$    cmp    #KEY_LEFT
  840.     bne    2$
  841.     jmp    PageUp
  842. 2$    jmp    PageDown
  843. iconXLTab:
  844. .byte    BOXRIGHT,BOXRIGHT-16,BOXRIGH
  845. iconXLTab:
  846. .byte    BOXRIGHT,BOXRIGHT-16,BOXRIGHT-(16*2)
  847. .byte    BOXRIGHT-(16*3),BOXRIGHT-(16*4)
  848. .byte    BOXRIGHT-(16*5)
  849. iconExecTab:
  850. .word    ScrollUp-1,ScrollDown-1,PageUp-1,PageDown-1
  851. .word    TopScroll-1,BotScroll-1
  852. fBoxIcons:
  853. .ramsect
  854. highest:    .block    1    ;Highest entry # in buffer
  855. ontop:    .block    1    ;entry # on top of window
  856. selected:    .block    1    ;Currently selected entry #
  857. nameWidth:    .block    1    ;width of each entry
  858. boxStyle:    .block    1    ;style of box text
  859. fbTemp:    .block    1
  860. FileTemp:    .block    1
  861. WorkDrive:    .block    1
  862. maxDrives:    .block    1
  863. TotalDrives:
  864.     .block    1
  865. SourceDrive:
  866.     .block    1    
  867. TargetDrive:
  868.     .block    1    
  869. DATA_TYPE:    .block    1
  870. NewLength:    .block    1
  871. list:    .block    2
  872. OldName:    .block    17
  873. NewName:    .block    17
  874. DriveAName:    .block    17
  875. DriveBName:    .block    17
  876. DriveCName:    .block    17
  877.